/**
 * Created by lxh on 2018/1/30.
 */
import React,{PureComponent}from 'react';
import {Modal} from 'antd';
export function powerControl(ButtonComponent){
    class WrapComponent extends PureComponent {
        constructor(props) {
            super(props);
        }

        // info=()=>{
        //      const modal = Modal.info({
        //          title: '权限不足，请找管理员申请',
        //          content: '该消息3秒之后会自动关闭...',
        //      });
        //         setTimeout(() => modal.destroy(), 3000);
        //  }
        returnFlag=(element)=>{
            let actionCodeList=JSON.parse(localStorage.getItem("userInfoState")).actionCodeList;
            for(let i=0;i<actionCodeList.length;i++){
                if(actionCodeList[i]===element){
                    return true;
                }
            }
            return false;
        }
        render() {
            if (this.returnFlag(this.props.auth)) {
                return <ButtonComponent {...this.props}/>;
            } else {
                return <ButtonComponent  disabled={true}  { ...this.props}/>;
            }
        }
    }
    return WrapComponent;
};